package com.zsc.projectmanagementapi.controller;

import com.zsc.projectmanagementapi.commons.ServerResponse;
import com.zsc.projectmanagementapi.pojo.Do.Project;
import com.zsc.projectmanagementapi.service.Impl.SearchServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Bernie_fang
 * @Description:
 * @create 2021/6/26 9:34
 **/
@RestController
public class SearchController {

    @Autowired
    private SearchServiceImpl searchService;

    @GetMapping("/findProject")
    public ServerResponse findProject(@RequestParam String name, @RequestParam String owner, @RequestParam String category){
        // List<String> allCategory = searchService.findAllCategory();
        System.out.println("name: " + name);
        System.out.println("owner: " + owner);
        System.out.println("category: " + category);

        List<Project> projectList = searchService.findProject(name, owner, category);
        return ServerResponse.createBySuccess(projectList);
    }

    @GetMapping("/findAllCategory")
    public ServerResponse findAllCategory() {
        List<String> allCategory = searchService.findAllCategory();
        return ServerResponse.createBySuccess(allCategory);
    }



}
